package com.youaishujuhui.devops.web.exception;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import com.youaishujuhui.devops.web.util.WebUtil;


/**
 * 
* @Description: 全局异常处理
* @author chendongming
* @date 2018年5月15日 下午8:30:56
*
 */
@Component
public class CustomExceptionResolver implements HandlerExceptionResolver{
	
	private Logger log = LoggerFactory.getLogger(CustomExceptionResolver.class);
	
    @Override  
    public ModelAndView resolveException(HttpServletRequest request,  
            HttpServletResponse response, Object handler, Exception ex) {  
        
        log.error(String.format("%s 异常拦截处理 %s ",request.getRequestURI(),ex.getMessage()),ex);
        
        return WebUtil.response(request, response, ex);
          
    }

	
    
}
